-
-
Notifications
You must be signed in to change notification settings - Fork 432
Adding magics
functionality to the litellm
implementation
#1437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@srdas This looks great, thank you! Just a few comments. Haven't tested it yet, have to join standup now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@srdas This is a great start, thank you! Just one extra comment below.
In addition, I've opened some follow-up issues (titled [magics] ...
) for you to explore. They can be addressed in separate PRs.
This is already a fantastic start, and I'm excited to merge this once the last comment is addressed.
self.transcript.append({"role": "user", "content": prompt}) | ||
self.transcript.append({"role": "assistant", "content": output}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you bound this list to be of length self.max_history * 2
? Right now, the ai()
method is manually truncating self.transcript
every time it appends it to the chat history. It would be more reliable to add some logic to bound the length of self.transcript
in the _append_exchange()
method itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is now done. Tested everything to make sure it is working. Here is a notebook if you want to test all the magics features (unzip to use).
magics_litellm.ipynb.zip
Refactored various functionality for the
%ai
and%%ai
magics to use the newlitellm
backbone added in PR #1426 . Fixes Issue #1432run_ai_cell
to invokelitellm
instead oflangchain
.register
command toalias
which is more natural when registering an alias for amodel_id
.delete
command todealias
which is more natural.update
command as it is working well and is convenient.help
is working and shows the updated commands.list
command to show model IDs and aliases.reset
command is working.default_language_model
toinitial_language_model
.aliases
toinitial_aliases
.error
command tofix
, updated it's handling..env
approach.See the demo below showing all of it working:
Screen.Recording.2025-07-30.at.2.30.01.PM.mov
Nice to have (among other items):
format
options to be much more stable using agentic capabilities with better prompts.widgets
as another output format option.TODO
commented items inmagics.py
for consideration.